import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class FileManagerMIDlet extends MIDlet{
	
	private Display display;
	private Alert a;
	private ListRoot root;
	private ListContend contend;
	private CreateFile createfile;
	private DeleteFile deletefile;
	private AudioPlayer audioplayer;
	private VideoPlayer videoplayer;
	private CalculatorTool calculator;
	private TextEditor texteditor;
	
	public FileManagerMIDlet(){
		display = Display.getDisplay(this);	
		root = new ListRoot(this);
		contend = new ListContend(this, display);			
	}
	
	public void startApp(){
		showRoot();		
	}
	
	public void pauseApp(){

	}

	public void destroyApp(boolean unconditional){

	}
	public void showRoot(){
		display.setCurrent(root);
	}
	public void showContend(String url, String filename){
		contend.getContend(url, filename);		
		display.setCurrent(contend);
	}
	public void showCreateForm(){		
		createfile = new CreateFile(this, contend, contend.URL());
		display.setCurrent(createfile);
	}
	public void showDeleteForm(String upurl, String fileurl){
		deletefile = new DeleteFile(this, contend, upurl, fileurl);
		display.setCurrent(deletefile);
	}
	public void playAudio(String url, String filename){
		audioplayer = new AudioPlayer(this, contend, url, filename, display);
		display.setCurrent(audioplayer);
	}
	public void playVideo(String url, String filename){
		videoplayer = new VideoPlayer(this, url, filename);
		display.setCurrent(videoplayer);
	}
	public void showCalculator(Displayable previousdisplay){
		calculator = new CalculatorTool(this, previousdisplay, display);
		display.setCurrent(calculator);
	}
	public void showAlert(String info, Displayable nextdisplay){
		a = new Alert("Message", info, null, null);
		display.setCurrent(a, nextdisplay);
	}	
	public void showTextEditor(){
		texteditor = new TextEditor(this, display, contend);
		display.setCurrent(texteditor);
	}
	public void exit(){
		destroyApp(false);
		System.gc();
		notifyDestroyed();
	}
}